#define _CRT_SECURE_NO_WARNINGS 1
//倒置字符串
//https://www.nowcoder.com/questionTerminal/8869d99cf1264e60a6d9eff4295e5bab
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;

//双指针
int main() {
    string s;
    getline(cin, s);
    reverse(s.begin(), s.end());
    auto start = s.begin();
    while (start != s.end())
    {
        auto end = start;
        while (end != s.end() && *end != ' ')
        {
            end++;
        }
        //出来就一定会翻转
        reverse(start, end);
        //翻转后更新迭代器
        //未走到末尾，即走到空格
        if (end != s.end())
        {
            start = end + 1;
        }
        //走到末尾
        else
        {
            start = end;
        }
    }
    cout << s << endl;
    return 0;
}
